<% crlf=CHR(13)+CHR(10) SET CENTURY ON m_transid=orequest.form('thetransid') if isnull(m_transid) m_transid=orequest.querystring('t') endif *theuser=orequest.querystring('user') pagetype=lower(transform(orequest.querystring('pw'))) * 80mm * * * * * *@page {size: | auto | [ || [ landscape | portrait ] ]} do case case [mix] $ pagetype isurdu=2 case [local] $ pagetype isurdu=1 OTHER isurdu=0 endcase do case case pagetype='pos' pagewidth='80mm' pageheight='3276mm' case pagetype='a4' pagewidth='8.3inch' pageheight='11.7inch' case pagetype='a5' pagewidth='5.8inch' pageheight='8.3inch' case pagetype='a6' pagewidth='4.1inch' pageheight='5.8inch' OTHER pagewidth='8.3inch' pageheight='11.7inch' endcase theuser=[] if isnull(m_transid) tsql=[select top 1 *,IIF(VAL(transid)=0,VAL(SUBSTR(transid,2)),VAL(transid)) AS VTR, ] tsql=tsql+[ padl(allt(transid),9) as ptransid ] tsql=tsql+[ from ("]+dbclocation+'cashsale.dbf'+[") order by vtr desc, ptransid desc ] else tsql=[select top 1 *,IIF(VAL(transid)=0,VAL(SUBSTR(transid,2)),VAL(transid)) AS VTR, ] tsql=tsql+[ padl(allt(transid),9) as ptransid ] tsql=tsql+[ from ("]+dbclocation+'cashsale.dbf'+[") order by vtr desc, ptransid desc where allt(transid)==']+allt(m_transid)+['] endif &tsql SCATTER NAME SearchResults if TYPE('SearchResults.fbrinv')='C' and not ALLTRIM(SearchResults.fbrinv)=='0' and not EMPTY(SearchResults.fbrinv) fbrnumberreceived=allt(searchresults.fbrinv) else fbrnumberreceived=[] endif if empty(date) thedatestring=date() &&transform(date()) else thedatestring=date &&transform(dtoc(date)) endif openingbalance=[] if BETWEEN(val(left(SearchResults.depositid,2)),1,8) and left(SearchResults.depositid,3)<>'019' select sum(debit-credit) as dayopening from (dbclocation+[acctran]) where accountid=SearchResults.depositid and date]+ALLTRIM(accounts.name)+[] =SEEK(SearchResults.depositid,[accounts],[accountid]) cdebitor=[] invnum=searchresults.transid CLOSE TABLES CLOSE DATABASES ************* USE IN SELECT('printinvoice') lgetunit=iif(xcompany.zunit or xcompany.usekglibs,.t.,.f.) haskglibs=xcompany.usekglibs IF NOT EMPTY(xcompany.fbrposid) tsql=[Select d.name as deposited,x.depositid, x.Total As PrdTotal,x.opt, x.fbrinv, x.fbrPOST, x.daysrno, x.discount As prdDisc, x.memdisc, ] tsql=tsql+[a.TAXPRATE, a.TAXRATE,a.extra, x.Payment, x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill, ] tsql=tsql+[x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer, ]+ iif(lgetunit=.t.,'z.unit','0')+[ as zunit, ] + iif(xcompany.zctn=.t.,'z.ctn','space(2)')+[ as zctn, ] tsql=tsql+[z.saleman as ySaleman, Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ] tsql=tsql+[z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,]+iif(haskglibs,'a.kgs','0')+[ as kgs,]+iif(haskglibs,'a.libs','0')+[ as libs,z.bonus,z.rate,IIF(EMPTY(z.purchase),a.cost,z.purchase) as cost, a.trade ,x.dtime,x.srvchgs, z.discount, z.Total, z.expiry ] tsql=tsql+[FROM (']+dbclocation+[cashsale') x LEFT join (']+dbclocation+[ACCOUNTS') Y ON (x.customer=y.accountid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[cashdata') z ON (x.transid=z.transid) LEFT join (']+dbclocation+[itemmast') a ON (z.itemid=a.itemid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[accounts') d ON (x.customer=d.accountid) ] tsql=tsql+[WHERE x.transid==']+invnum+[' Order By z.transid, x.Date, z.sr_no INTO cursor ('printinvoice') readwrite ] &tsql ELSE tsql=[Select d.name as deposited,x.depositid, x.Total As PrdTotal,x.opt, space(9) as fbrinv, space(9) as fbrPOST, x.daysrno, x.discount As prdDisc, x.memdisc, ] tsql=tsql+[a.TAXPRATE, a.TAXRATE,a.extra, x.Payment, x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill, ] tsql=tsql+[x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer, ]+ iif(lgetunit=.t.,'z.unit','0')+[ as zunit, ] + iif(xcompany.zctn=.t.,'z.ctn','space(2)')+[ as zctn, ] tsql=tsql+[z.saleman as ySaleman, Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ] tsql=tsql+[z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,]+iif(haskglibs,'a.kgs','0')+[ as kgs,]+iif(haskglibs,'a.libs','0')+[ as libs,z.bonus,z.rate,IIF(EMPTY(z.purchase),a.cost,z.purchase) as cost, a.trade ,x.dtime,x.srvchgs, z.discount, z.Total, z.expiry ] tsql=tsql+[FROM (']+dbclocation+[cashsale') x LEFT join (']+dbclocation+[ACCOUNTS') Y ON (x.customer=y.accountid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[cashdata') z ON (x.transid=z.transid) LEFT join (']+dbclocation+[itemmast') a ON (z.itemid=a.itemid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[accounts') d ON (x.customer=d.accountid) ] tsql=tsql+[WHERE x.transid==']+invnum+[' Order By z.transid, x.Date, z.sr_no INTO cursor ('printinvoice') readwrite ] &tsql endif thedeposited=deposited =changeFieldStruc() IF EMPTY(memo) AND depositid<>[019] replace ALL memo WITH thedeposited ENDIF XDISCLABEL=[] rept_saleman=[] hastax=.f. hasdiscount=.f. haszunit = .f. haszctn = .f. haskglibs=xcompany.usekglibs SCAN if not empty(kgs) or not empty(libs) haskglibs=xcompany.usekglibs endif if not empty(zunit) haszunit= .t. endif if not empty(zctn) haszctn= .t. endif if not empty(taxprate) or not empty(taxrate) hastax=.t. endif if not empty(discount) hasdiscount=.t. endif replace cost WITH NVL(cost,0), trade WITH NVL(trade,0), sr_no WITH RECNO() IF discount<>0 XDISCLABEL=[DISC] ENDIF IF NOT EMPTY(saleman) rept_saleman=IIF(SEEK(saleman,[accounts],[accountid]),accounts.name,[]) endif theuser=allt(opt) endscan If xcompany.haspart PartsValue=0 partsQty=0 Select 'printinvoice' Go Top Scan If Seek(ItemID,'itemmast','itemid') And itemmast.ispart PartsValue=PartsValue+(rate*qty-discount) partsQty=partsQty+qty Scatter Name saveit Delete ENDIF IF discount<>0 XDISCLABEL=[DISC] endif Endscan If PartsValue<>0 Append Blank Gather Name saveit Replace Desc With 'REPAIR CHARGES',; qty With partsQty,; rate With (PartsValue)/partsQty,; total With PartsValue Endif Endif go top STORE 0 TO TOTALTAX, fbrservice, SERVICECHARGES, TOTALAMOUNT, PRODUCTDISCOUNT,; MEMBERDISCOUNT, NETAMOUNT, RECEIVEDAMOUNT, BALANCEAMOUNT IF type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv) fbrservice=1 endif SERVICECHARGES=srvchgs TOTALAMOUNT=ROUND(Printinvoice.prdtotal+printinvoice.srvchgs,0) PRODUCTDISCOUNT=prdDisc MEMBERDISCOUNT=memdisc netamount=ROUND(Printinvoice.prdtotal+fbrservice-Printinvoice.prdDISC-PRINTINVOICE.MEMDISC+printinvoice.srvchgs,0) RECEIVEDAMOUNT=iif(empty(payment),netamount,payment) BALANCEAMOUNT=RECEIVEDAMOUNT-netamount cspan=1 ************* %>

<%=xcompany.name%>

<%=allt(allt(xcompany.address1)+[ ]+allt(xcompany.address2))%>

<%if not empty(xcompany.ntn)%>

<%=iif(left(searchresults.depositid,3)=[019],[CASH SALE],[DEBIT SALE])%>
<%=xcompany.ntn%>

<%else%>

<%=iif(left(searchresults.depositid,3)=[019],[CASH SALE],[DEBIT SALE])%>

<%endif%> <%if not empty(xcompany.fbrposid) or not empty(fbrnumberreceived)%>

<%if not empty(xcompany.fbrposid) %> <%endif%> <%if not empty(fbrnumberreceived)%> <%endif%>

<%endif%> <%if type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv)%>

<%=[POSID# ]+ALLT(xcompany.fbrposid)%> <%=[FBR# ]+ALLT(fbrinv)%>

<%endif%> <%if not empty(memo)%>

<%=allt(memo)%>

<%endif%>

<%=[INV# ]+ALLT(TRANSID)+[ ]+ttoc(dtime)%>

<%if haskglibs%> <%else%> <%if haszctn%> <%endif%> <%if haszunit%> <%endif%> <%endif haskglibs%> <%if hastax=.t.%> <%endif%> <%if hasdiscount%> <%endif%> <%SCAN%> <% ITEMTX=round(iif(empty(taxprate),taxrate*qty,(qty*rate)-(qty*rate)/(1+taxprate/100)),2) if empty(taxprate) thetaxprate=round((taxrate/(rate-taxrate))*100,2) else thetaxprate=taxprate endif SALEINCLUDINGTAX=qty*rate saleexcludingtax=saleincludingtax-itemtx totaltax=totaltax+itemtx thechars=[] textra=allt(nvl(extra,'')) for i=1 to len(textra) thechars=thechars+[ | ]+subst(textra,i,1)+[ : ]+transform(asc(subst(textra,i,1))) endfor testunits=nvl(zunit,0) kgqty=QTY*iif(empty(KGS),1,kgs) libsqty=QTY*iif(empty(libs),2.20462,libs) kgqty=icase(kgqty=round(kgqty,0),round(kgqty,0),kgqty=round(kgqty,2),round(kgqty,2),kgqty=round(kgqty,3),round(kgqty,3),round(kgqty,4)) libsqty=icase(libsqty=round(libsqty,0),round(libsqty,0),libsqty=round(libsqty,2),round(libsqty,2),libsqty=round(libsqty,3),round(libsqty,3),round(libsqty,4)) rateperlib=saleexcludingtax/libsqty if haskglibs if empty(kgs) thectnqty=iif(empty(testunits),qty,testunits) else thectnqty=qty endif rateperkg=saleexcludingtax/kgqty else thectnqty=qty rateperkg=saleexcludingtax/qty endif rateperkg=icase(rateperkg=round(rateperkg,0),round(rateperkg,0),round(rateperkg,2)) rateperlib=icase(rateperlib=round(rateperlib,0),round(rateperlib,0),round(rateperlib,2)) %> <%if haskglibs%> <%else%> <%if haszctn%> <%endif%> <%if haszunit%> <%endif%> <%endif haskglibs%> <%if hastax=.t.%> <%endif%> <% roundeddisc=icase(discount=round(discount,0),round(discount,0),round(discount,2)) %> <%if hasdiscount%> <%endif%> <%ENDSCAN%>
# DETAILSKGs LIBs CTNs RATE/LIB RATE/KGUNITPCSQTY RATETAX% VATTOTALDISC NET AMOUNT
<%=RECNO()%> <%=icase(isurdu=2,allt(DESC)+iif(empty(textra),[],[
]+allt(textra)),isurdu=1,iif(empty(textra),allt(desc),allt(textra)),allt(desc))%>
<%=iif(empty(KGQTY),' ',KGQTY)%> <%=iif(empty(libsQTY),' ',libsQTY)%> <%=iif(empty(thectnqty),' ',thectnqty)%> <%=iif(empty(rateperlib),' ',rateperlib)%> <%=iif(empty(rateperkg),' ',rateperkg)%><%=zctn%><%=iif(empty(thectnqty),' ',thectnqty)%><%=thectnqty%> <%=rateperkg%><%=iif(empty(thetaxprate),' ',transform(thetaxprate)+[%])%> <%=iif(empty(itemtx),' ',transform(itemtx,'999999999.99'))%><%=ROUND(qty*rate,0)%><%=iif(empty(roundeddisc),' ',transform(roundeddisc))%> <%=ROUND(qty*rate-roundeddisc,0)%>
<%if hastax=.t.%> <%if totaltax<>0 %> <%endif%> <%endif%> <%if fbrservice<>0 %> <%endif%> <%if SERVICECHARGES<>0 %> <%endif%> <%if round(PRODUCTDISCOUNT+MEMBERDISCOUNT,2)<>0 %> <%endif%>
TOTAL TAX<%=TOTALTAX%>
POS SERVICE CHARGES<%=fbrservice%>
SERVICE CHARGES<%=SERVICECHARGES%>
TOTAL AMOUNT<%=TOTALAMOUNT+fbrservice+SERVICECHARGES%>
DISCOUNT<%=PRODUCTDISCOUNT+MEMBERDISCOUNT%>
NET AMOUNT<%=TOTALAMOUNT+fbrservice+SERVICECHARGES-PRODUCTDISCOUNT-MEMBERDISCOUNT%>
<% LASTMESSAGE=[] IF NOT EMPTY(XCOMPANY.CUSTMSG1) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG1)+[ ] ENDIF IF NOT EMPTY(XCOMPANY.CUSTMSG2) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG2)+[ ] ENDIF IF NOT EMPTY(XCOMPANY.CUSTMSG3) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG3)+[ ] ENDIF IF NOT EMPTY(XCOMPANY.CUSTMSG4) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG4)+[ ] ENDIF %>

<%='OPERATOR '+ALLT(theuser)+' '+IIF(EMPTY(REPT_SALEMAN),'','SOLD BY: '+REPT_SALEMAN)%>

<%if NOT EMPTY(LASTMESSAGE) %>

<%=LASTMESSAGE%>

<%endif%>
<% CLOSE TABLES CLOSE DATABASES USE IN SELECT([printinvoice]) %>